<?php if (!defined('ITPK')) exit('You can not directly access the file.');

/**
 * 机器人登录验证码操作类
 * @author 冬天的秘密
 * @link http://bbs.itpk.cn
 * @version 1.0
 */

class WebverificationPer extends WebDBConnection {

	/**
	 * 获取验证码
	 * @param string $uin
	 * @return string | boolean
	 */
	public function getMeByUin($uin) {
		$verification = $this->db->executeQuery("SELECT verification FROM web_verification WHERE uin = '{$uin}' ORDER BY id ASC LIMIT 1", true);
		return $verification ? $verification['verification'] : false;
	}

	/**
	 * 更新或添加验证码
	 * @param string $uin
	 * @param string $verification
	 * @return boolean
	 */
	public function replaceMe($uin, $verification) {
		$count = $this->db->executeQuery("REPLACE INTO web_verification(uin, verification) VALUES('{$uin}', '{$verification}')");
		return $count > 0 ? true : false;
	}

} 
?>